package net.dotool;

import java.util.HashMap;
import java.util.Map;

/**
 * json相关转换
 * @author 李岩飞
 * @email eliyanfei@126.com	
 * 2017年10月27日 下午3:52:30
 * 
 */
public class ConvertTools {
	/**
	 * ["a=12","b=13"]
	 * 数组转map
	 */
	public static Map<String, String> strToMap(String... strings) {
		Map<String, String> map = new HashMap<String, String>();
		if (strings != null) {
			for (String str : strings) {
				String[] arrs = str.split("=");
				if (arrs.length == 2)
					map.put(arrs[0], arrs[1]);
			}
		}
		return map;
	}

	public static Map<String, String> arrayToMap(String... strings) {
		Map<String, String> map = new HashMap<String, String>();
		if (strings != null) {
			for (int i = 0; i < strings.length;) {
				map.put(strings[i], strings[i + 1]);
				i = i + 2;
			}
		}
		return map;
	}
}
